package com.ics.web.controller.travelstar.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ics.framework.util.PageUtil;
import com.ics.web.controller.travelstar.domain.TravelstarForm;
import com.ics.web.controller.travelstar.dto.TravelstarFormDTO;
import com.ics.web.controller.travelstar.mapper.TravelstarFormMapper;
import com.ics.web.controller.travelstar.service.TravelstarFormService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author shaoly
 * @description
 * @ClassName TravelstarFormServiceImpl.java
 * @createTime 2024年12月05日 13:36:56
 */
@Service
@Slf4j
public class TravelstarFormServiceImpl extends ServiceImpl<TravelstarFormMapper, TravelstarForm> implements TravelstarFormService {


    @Override
    public IPage<TravelstarForm> listPage(TravelstarFormDTO formDTO) {
        LambdaQueryWrapper<TravelstarForm> wrapper = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(formDTO.getFormName())) {
            wrapper.like(TravelstarForm::getFormName, formDTO.getFormName());
        }
        if (StringUtils.isNotBlank(formDTO.getBigType())) {
            wrapper.eq(TravelstarForm::getBigType, formDTO.getBigType());
        }
        if (StringUtils.isNotBlank(formDTO.getSmallType())) {
            wrapper.eq(TravelstarForm::getSmallType, formDTO.getSmallType());
        }
        wrapper.orderByAsc(TravelstarForm::getFOrder);
        return this.baseMapper.selectPage(PageUtil.getPage(formDTO), wrapper);
    }
}
